class Project < ActiveRecord::Base
	has_and_belongs_to_many :users
	has_many :tasks
	
	validates_presence_of :title
	validates_presence_of :currency
	validates_numericality_of :budget, :greater_than_or_equal_to => 0.0
	validates_numericality_of :hourly_rate, :greater_than_or_equal_to => 0.0
	
	def unfinished_tasks
		Task.find_all_by_project_id_and_finished(self,false)
	end
	
	def finished_tasks
		Task.find_all_by_project_id_and_finished(self,true)
	end
	
	def team_members
		self.users
	end
end
